home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / chat / reflect.000 / reflect / 3.0b3 / reflect.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-18  |  15.8 KB  |  463 lines

  1. /*
  2.  
  3. Copyright 1993, 1994, Cornell University
  4.  
  5. Cornell hereby grants permission to use, copy, modify, and distribute this program for any purpose 
  6. and without fee, provided that these copyright and permission notices appear on all copies and 
  7. supporting documentation, the name of Cornell not be used in advertising or publicity pertaining 
  8. to distribution of the program without specific prior permission, notice be given in supporting 
  9. documentation that copying and distribution is by permission of Cornell.  CORNELL MAKES NO 
  10. REPRESENTATIONS OR WARRANTEES, EXPRESS OR IMPLIED.  By way of example, but not limitation, 
  11. CORNELL MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR 
  12. PURPOSE OR THAT THE USE OF THIS SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, 
  13. TRADEMARKS, OR OTHER RIGHTS.  Cornell shall not be held liable for any liability with respect to 
  14. any claim by the user or any other party arising from use of the program.
  15.  
  16. This material is partially based on work sponsored by the National Science Foundation under Cooperative 
  17. Agreement No. NCR-9318337.  The government has certain rights in this material.
  18.  
  19. */
  20.  
  21. #include <sys/time.h>
  22.  
  23. /* address families */
  24.  
  25. #define kGroup                0
  26. #define kClient                1
  27. #define kReflector            2
  28.  
  29. /* data types */
  30. #define kMinVideoDataType        1
  31. #define kHalfSizeVideoType        1
  32. #define kFullSizeVideoType        2
  33. #define kMaxVideoDataType        2
  34. #define kAudio                3
  35.  
  36. #define kAuxDataTypeSupervisor          256
  37. #define kAuxDataTypeData                257
  38.  
  39. #define kControlType            100
  40. #define kConfigVideoType        101
  41. #define kPacketLossReport        102
  42. #define kAckType            103
  43. #define kMessageType1                   104
  44. #define kMessageType2                   105
  45. #define kConfigRefType                106
  46.  
  47. /* video control messages */
  48. #define kNoMessage            0
  49.     
  50. #define kOpenConnection            1
  51. #define kStartVideo            2
  52. #define kModifyVideo            3
  53. #define kRefuseVideo            4
  54. #define kStopVideo            5
  55. #define kCloseConnection        6
  56.  
  57.  
  58. #define kBCCOpen                        100
  59. #define kREFOpen                        101
  60.  
  61.  
  62. #define kGotOpen        -kOpenConnection
  63. #define kGotStart        -kStartVideo
  64. #define kGotModify        -kModifyVideo
  65. #define kGotRefuse        -kRefuseVideo
  66. #define kGotStop        -kStopVideo
  67. #define kGotClose        -kCloseConnection
  68.  
  69. #define kContinueConnection        12
  70. #define kSuspendMessage            13
  71.  
  72. #define kFrameEndMessage        20
  73.  
  74.  
  75. /* connect mode */
  76. #define kInternal            -1
  77. #define kNoConnection            0
  78. #define kWaitingForOpenAck        1
  79. #define kWaitingForClientAck        2
  80. #define kSuspended            3
  81. #define kConnected            4
  82.  
  83. /* send/receive mode */
  84. #define kNoVideoSource            -1
  85. #define kNoSize                0
  86. #define kHalfSize            1
  87. #define kFullSize            2
  88. #define kDefaultSize            100
  89.  
  90. /* copy mode */
  91. #define kAsIs                0
  92. #define kHalf                1
  93. #define kDouble                2
  94.  
  95. /* grab frame mode */
  96. #define kNoFrames            0
  97. #define kGrab1Frame            1
  98. #define kGrab2Frames            2
  99.  
  100. #define VERSION_STRING                   "3.00B3"
  101. #define VERSION_NUM                     2
  102. #define LOGFILE                         "reflect.log"
  103. #define CONFIGFILE            "reflect.conf"
  104. #define DENY_ACCESS            "You are not currently permitted access to this reflector."
  105. #define MAX_CL                          "Sorry, maximum number of users exceeded."
  106. #define CFD                             "Sorry, the Conference ID has changed.  Please reconnect with the correct one."
  107. #define CAPMSG                          "Please lower you cap to 80kbits."
  108. #define MLMSG                           "Maximum # of lurkers exceeded - try again later."
  109. #define MSMSG                           "Maximum # of senders exceeded - try again later."
  110.  
  111.  
  112. #define VID_PORT             7648
  113. #define CONTROL_PORT             7649   
  114. #define NV_PORT             7650   
  115. #define RF_PORT             7651   
  116.  
  117.  
  118. #define MAXMSG                 2048
  119. #define MAXCLIENT             40
  120. #define DEFMAXCLIENT             20
  121. #define MAXSRCREF              20 
  122. #define MAXNVSTREAMS                    8
  123.  
  124. #define CONFBUF                         2000
  125. #define MOTDBUF                         800
  126. #define MSGBUF                          80
  127.  
  128. #define VIDEO                 1
  129. #define CONTROL             2
  130. #define REF1VIDEO             3
  131. #define REF2VIDEO             4
  132. #define MAVEN                5
  133. #define MAVEN_CNTL            6
  134.  
  135. #define VAT                             7
  136. #define VAT_CNTL                        8
  137. #define NV_MCAST                        9
  138. #define NV_UCAST                        10
  139.  
  140. #define ACKOPEN             3
  141. #define TIMEOUT             15 
  142. #define KALIVE                     2 
  143. #define TRATE                     10 
  144. #define HRATE                     60 
  145. #define NV_SDESC_TIMER                  5
  146. #define NV_OCP_TIMER                    5
  147. #define VAT_SPEAKER_INTERVAL            300
  148.  
  149.  
  150. #define MHEADERLEN                      8
  151. #define NVVERSION                       0x40
  152. #define NVCONTENT                       27
  153. #define SSRCLEN                         8
  154. #define NVOBIT                          0x80
  155. #define NVSBIT                          0x40
  156. #define SDESC                           33
  157. #define FINAL                           0x80
  158. #define SSRC                            1
  159. #define NV_CHAN                         32
  160. #define RTP_EPOCH_OFFSET                ((unsigned long) 2208988800)
  161. #define NV_CLIENT_VERS                  20
  162.  
  163. #ifndef TRUE
  164. #define TRUE 1
  165. #endif
  166.  
  167. #ifndef FALSE
  168. #define FALSE 0
  169. #endif
  170.  
  171.  
  172. typedef struct PacketLossData 
  173. {
  174.     unsigned short  packetsSent;
  175.     unsigned short  packetsRecv;
  176. } PacketLossData;
  177.  
  178.  
  179. typedef struct addr
  180. {
  181.     short           family;        
  182.     unsigned short  port;
  183.     unsigned long   addr;
  184. } addr;
  185.  
  186. typedef struct Routing {
  187.     addr            dest;
  188.     addr            src;
  189. } Routing;
  190.  
  191. typedef struct VideoPacketHeader {
  192.     Routing         routing;           /* 16 byte socket header for exploder */
  193.     unsigned long   seqNum;
  194.     short           message;
  195.     short           dataType;
  196.     short           len;
  197. } VideoPacketHeader;
  198.  
  199. #define HEADERLEN 26
  200.  
  201. #define conferenceid routing.dest.port
  202.  
  203. typedef struct OpenContinueData 
  204. {
  205.         short            clientCount;
  206.         unsigned long        seqNum;
  207.         char            name[20];
  208.         unsigned char        sendMode;
  209.         unsigned char        recvMode;
  210.         unsigned char        flags;
  211.         unsigned char        version;
  212. /*  
  213.     ClientInfo        clients[clientCount] 
  214. */
  215. } OpenContinueData;
  216.  
  217. #define OCDLEN 30
  218.  
  219. #define REC_AUDIO        0x01
  220. #define AUDIO_CAPABLE        0x02
  221. #define WANT_LURCKERS        0x04
  222. #define PC_CLIENT        0x08
  223. #define PRIVATE_AUDIO           0x10
  224. #define WANT_VERSION            0x20
  225.  
  226. #define VERSION1                1
  227. #define VERSION5                5
  228.  
  229. typedef struct ClientInfo 
  230. {
  231.         unsigned long        clientIP;
  232.         char            flags;
  233.         char            aux;
  234.         char            IWillRecv;
  235.         char            IWillSend;
  236.         PacketLossData        loss;
  237. } ClientInfo;
  238.  
  239. #define CILEN 12
  240.  
  241. #define UPDATE_VIDEO    0x01
  242. #define UPDATE_AUDIO    0x02
  243. #define IWillRecAudio   0x04
  244. #define UPDATE_AUXDATA  0x08
  245.  
  246. typedef struct OpenContinuePacket 
  247. {
  248.         VideoPacketHeader    header;
  249.         OpenContinueData    config;
  250. } OpenContinuePacket;
  251.  
  252. typedef struct ControlPacket 
  253. {
  254.     VideoPacketHeader   header;
  255. } ControlPacket;
  256.  
  257. typedef struct slist
  258. {
  259.    struct   slist    *snd_nptr;
  260.    struct   client   *snd_client;
  261.    unsigned long     snd_auxmask;
  262. } slist;
  263.  
  264. typedef struct client 
  265. {
  266.     struct client     *clnt_nptr;           /* next client                                        */
  267.     struct client     *clnt_pptr;           /* ptr to REF3_SOURCE if this client is a REF3_ORIGIN */
  268.     addr              clnt_addr;            /* client's address                                   */
  269.     slist             *clnt_vlist;          /* list of clients receiving video                    */
  270.     slist             *clnt_alist;          /* list of clients receiving audio                    */
  271.     slist             *clnt_xlist;          /* list of clients receiving aux data                 */
  272.     short             clnt_rtimer;          /* client's recieve timer                             */
  273.     short             clnt_stimer;          /* client's send timer                                */
  274.     short             clnt_ntimer;        /* timer for sending OCP for nv clients               */
  275.     short             clnt_id;            /* client's id                                        */    
  276.     short             clnt_talker;          /* cnt of audio pkts rec'ed - used for logging current speaker  */
  277.     short             clnt_caploop;         /* # of times through the timer loop before calculating CAP     */
  278.     short             clnt_hdloop;          /* # of times through the timer loop before deleting hold downs */
  279.     unsigned short    clnt_conf_id;         /* conference id the client connected with            */
  280.     unsigned long     clnt_flags;           /* flags                                              */
  281.     unsigned long     clnt_bytecnt;         /* byte count for video packets                       */
  282.     unsigned long     clnt_sdesc_time;      /* timestamp of last SDESC option transmitted         */
  283.     unsigned long     clnt_seq;             /* OCP seq # to send for nv clients                   */
  284.     unsigned long     clnt_ocp_cnt;         /* # of OCP sent on behalf of this client             */
  285.     struct timeval    clnt_tp;              /* time value used in calculating the byte cnt        */
  286.     OpenContinueData  clnt_config;          /* client's configuration                             */
  287. } client;
  288.  
  289. #define CLIENT        0x00000001            /* normal Mac/PC client                                       */
  290.  
  291. #define BCC_CLIENT    0x00000002            /* another reflector serving as a BCC client                  */
  292. #define BCC_ORIGIN    0x00000004            /* this client originates from a BCC server reflector         */
  293. #define BCC_SERVER    0x00000008            /* another reflector serving as a BCC server                  */
  294.  
  295. #define REF1_SERVER   0x00000010            /* another reflector serving as a multicast source            */
  296. #define REF1_ORIGIN   0x00000020            /* this client originates from multicast source reflector (one way)    */
  297. #define REF1_CLIENT   0x00000040            /* another reflector serving as a multicast recipient         */
  298.  
  299.  
  300. #define REF2_SERVER   0x00000080            /* another reflector participating in a 2way mcast            */
  301. #define REF2_ORIGIN   0x00000100            /* this client originates from multicast group  reflector (two way)    */
  302.  
  303. #define HOLD_DOWN     0x00000200            /* this client is being held down                             */
  304. #define DELETE        0x00000400            /* this client is deleted                                     */
  305.  
  306. #define REF3_SERVER   0x00000800            /* another reflector participating in a 2way ucast            */
  307. #define REF3_ORIGIN   0x00001000            /* this client originates from unicat group reflector (two way)    */
  308.  
  309. #define NV_UCLIENT    0x00002000            /* this is an NV unicast client                               */
  310. #define NV_MCLIENT    0x00004000            /* this is an NV multicast client                             */
  311.  
  312. #define BCC_GCLIENT   0x00008000            /* general bcc client                                         */
  313.  
  314. typedef struct 
  315. {
  316.    unsigned long site_id;
  317.    char     id_string[1];                   
  318. }  SiteId;
  319.  
  320. /* 
  321.    list to keep track of how long since each member of a vat mixer stream
  322.    last spoke.  The SiteId pointer points into the idlist of the maven client
  323.    which represents this vat-mixer.  The how_long field is a measure of how
  324.    many CTRL_TYPE_IDLIST messages the mixer has sent since the associated member
  325.    last spoke.  
  326. */
  327.  
  328. typedef struct VatMixerSpeaker 
  329. {
  330.    struct VatMixerSpeaker *next;
  331.    short spoke;                                /* tick count when this client last spoke */
  332.    SiteId *who;
  333. } VatMixerSpeaker;
  334.  
  335. #define MAX_MAVEN_NAME_LEN 40
  336.  
  337. typedef struct vat_client 
  338. {
  339.     struct vat_client     *mvn_nptr;           /* next client               */
  340.     struct vat_client     *mvn_pptr;           /* ptr to parent maven client if this is a mixer's client */
  341.     addr                  mvn_addr;            /* client's address          */
  342.     unsigned long         mvn_flags;           /* flags                                              */
  343.  
  344.     unsigned long         mvn_seq;             /* sequence #                */
  345.     unsigned long         mvn_ocp_seq;         /* sequence # for OCP        */
  346.     unsigned long         mvn_spoke;           /* tick count when this client last spoke */
  347.  
  348.     short                 mvn_rtimer;          /* client's recieve timer    */
  349.     short                 mvn_talker;          /* cnt of audio pkts rec'ed - used for logging current speaker */
  350.  
  351.     char                  mvn_recv_type;       /* MCAST or UCAST */
  352.     char                  mvn_name[MAX_MAVEN_NAME_LEN];            /* client's name  */
  353.  
  354.     struct IDMsgHdr       *mvn_idlist;         /* If this maven/vat client is a mixer and is sending
  355.                                                   CTRL_TYPE_IDLIST messages, then this is a pointer
  356.                                                   to the most up to date such message it has
  357.                                                   sent.  Otherwise NULL.  Note that often it is
  358.                                                   not a mixer but another reflector... but that
  359.                                                   is indistinguishable from our standpoint. */
  360.     int                   mvn_idlist_len;      /* the length of the above-mentioned idlist  */
  361.  
  362. } vat_client;
  363.  
  364. /* definitions for flags                                            */
  365. #define VAT_CLIENT         0x00000001      
  366. #define VAT_MIXER          0x00000002       
  367. #define VAT_MIXER_CLIENT   0x00000004        
  368.  
  369. #define SPEAK_OCP     60                      /* 
  370.                                                   if a maven client hasn't spoken for the last SPEAK_TIMEOUT seconds  
  371.                                                   then stop sending OCP on behalf of it to CUSM clients 
  372.                                                */
  373. #define MCAST 0
  374. #define UCAST 1
  375.  
  376. struct CtrlMsgHdr 
  377. {
  378.         unsigned char flags;
  379.         unsigned char type;
  380.         unsigned short confid;
  381.         char idmsg[1];
  382. };
  383.  
  384. #define CTRLMSGSIZE (4)
  385.  
  386. #define CTRL_TYPE_ID 1
  387. #define CTRL_TYPE_DONE 2
  388. #define CTRL_TYPE_IDLIST 3
  389.  
  390. /* 
  391.    the following structures have been added for the construction of
  392.    vat CTRL_TYPE_IDLIST message generation  
  393. */
  394.  
  395. struct IDMsgHdr 
  396. {
  397.   unsigned char flags;
  398.   unsigned char type;
  399.   unsigned short confid;
  400.   unsigned char nsids;
  401.   unsigned char ainfo;
  402.   unsigned short blksize;
  403. };
  404.  
  405. typedef struct 
  406. {
  407.    unsigned char nsid;
  408.    unsigned char flags;
  409.    unsigned short confid;
  410.    unsigned long ts;
  411. }  vat_hdr_t;
  412.  
  413. #define NSID_MASK      0x3f
  414. #define VATHF_NEWTS    0x80
  415. #define VATHF_FMTMASK  0x1f;
  416.  
  417. typedef struct nv_client
  418. {
  419.    struct nv_client *nv_nptr;          /* pointer to next nv_client in the list                     */
  420.    addr             nv_addr;           /* address of this client                                    */
  421.    slist            *nv_vlist;         /* list of CUSM clients receiving this NV's video            */
  422.    unsigned long    nv_flags;          /* flags                                                     */
  423.    short            nv_rtimer;         /* client's receive timer                                    */
  424.    short            nv_hdloop;         /* # of times through the timer loop before deleting hold downs */
  425. } nv_client;
  426.  
  427. #define UNICAST_NV        0x0001       /* this nv is coming in via unicast                          */
  428. #define MULTICAST_NV      0x0002       /* this nv is coming in via multicast                        */
  429.  
  430. typedef struct AuxDataHeader
  431. {
  432.     char          adhVersion;
  433.     char          adhHeaderLenght;
  434.     char          adhOpcode;
  435.     char          adhPriority;
  436.     unsigned long adhPrune;
  437.     char          adhStatus;
  438.     char          adhUNUSED1;
  439.     short         adhSegmentLength;
  440.     long          adhType;
  441.     long          adhItemNumber;
  442.     long          adhItemID;
  443.     long          adhItemLength;
  444.     long          adhSegmentOffset;
  445. } AuxDataHeader;
  446.  
  447. /* this is used to identify chunks of data that are tacked onto the end of OC packet's */
  448.  
  449. typedef struct
  450. {
  451.     short dataType;
  452.     short bytes;
  453. } OCExtraHeader;
  454.  
  455. #define kAuxTMAdvExtraType 1
  456.  
  457.  
  458. typedef struct
  459. {
  460.     short count;
  461.     short seqNum;
  462. } TMapHeader;
  463.